<?php

define("DEMO_DIR", dirname(__FILE__)."/..");
define("MODEL_DIR", DEMO_DIR."/model");

require_once(MODEL_DIR."/user.php");
require_once(MODEL_DIR."/userdao.php");
require_once(MODEL_DIR."/filesystem.php");

$user = new User();

$ret = $user->getStatus();

$ret = $user->register("liming", "111111", "liming@ccc.com");

$user->login("liming","111111");

# bind mac to location
$macaddress = "11-22-33-aa-bb-cc";
$location = User::STATUS_HOME | User::STATUS_PUBLIC;
$user->setLocation($location);

# set gesture
$user->setGesture("98765");

# update status
$user->updateStatus("liming", $macaddress);

$times = $user->getTrialTimes();
echo "initial trail times\n";
var_dump($times);

# unlock failed
$a=$user->unlockFromGesture("7777");
echo "unlock      error\n";
var_dump($a);

# trail time ++ 
$user->increamentTrialTimes();
$times = $user->getTrialTimes();
echo "increase trail times\n";
var_dump($times);

$a=$user->unlockFromGesture("98765");
echo "unlock      success\n";
var_dump($a);

# success clear trial times
$user->clearTrialTimes();
$times = $user->getTrialTimes();
echo "clear trail times\n";
var_dump($times);

function printUser()
{
    $ud = new UserDao();
    $ret = $ud->getUser("liming");
    var_export($ret);
    print PHP_EOL;
}




